import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from "@/views/Home.vue";
import Index from "@/views/Index.vue";
import Video from "@/views/Video.vue";
import Mine from "@/views/Mine.vue";
import Editor from "@/views/Editor.vue";
import Square from "@/views/Square.vue";
import ShowArticles from "@/views/ShowArticles.vue";
import Search from "@/views/Search.vue";
import ShowMine from "@/views/ShowMine.vue";
import Mana from "@/views/Mana.vue";
import PaperTch from "@/views/PaperTch.vue";
import Papers from "@/views/Papers.vue";
import PaperStu from "@/views/PaperStu.vue";

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        redirect:'home'
    },
    {
        path: '/home',
        name: 'Home',
        component: Home,
        redirect: '/square',
        children:[
            {
                path: '/mine',
                name: '/Mine',
                component: Mine
            },
            {
                path: '/editor',
                name: '/Editor',
                component: Editor
            },
            {
                path: '/square',
                name: '/Square',
                component: Square
            },
            {
                path: '/showMine',
                name: '/ShowMine',
                component: ShowMine
            },
            {
                path: '/video',
                name: '/Video',
                component: Video
            },
            {
                path: '/paperTch',
                name: '/PaperTch',
                component: PaperTch
            },
            {
                path: '/papers',
                name: '/Papers',
                component: Papers
            },
            {
                path: '/paperStu',
                name: '/PaperStu',
                component: PaperStu
            }
        ]
    },
    {
        path: '/index',
        name: 'Index',
        component: Index
    },
    {
        path: '/showArticles',
        name: '/ShowArticles',
        component: ShowArticles
    },
    {
        path: '/search',
        name: '/Search',
        component: Search
    },
    {
        path: '/mana',
        name: '/Mana',
        component: Mana
    },

]


// 防止多次点击路由报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
    routes
})

export default router
